package day1030_2;

class Employee{
    private  String  name;
    private  String phone;
    private  String email;
    public void setName(String name) throws ValidatorException {//159
        if( name!=null && (name.length()<2 || name.length()>4)  )
            throw  new ValidatorException("您输入的姓名长度超范围了。");
        this.name = name;
    }
    public void setPhone(String phone) throws ValidatorException {
        if(phone !=null && phone.length()!=11)
            throw  new ValidatorException("您输入手机号码格式不对。");
        this.phone = phone;
    }
    public void setEmail(String email) throws ValidatorException {
        String   check="^([A-Za-z0-9]+)*@([A-Za-z0-9]+[-.])+[A-Za-z0-9]{2,5}$";
        if(!email.matches(check))
            throw  new ValidatorException("您输入邮箱格式不对。");
        this.email = email;
    }

    public String getName() {
        return name;
    }



    public String getPhone() {
        return phone;
    }
    public String getEmail() {
        return email;
    }
}




public class ValidatorException  extends  Exception{//158
    //右键  generate    constructor
    public ValidatorException(String message) {
        super(message);
    }

}
